<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2016/10/17
 * Time: 14:52
 */

/*$dateTime='2016-02-27 12:54:57';
$res = explode('-',$dateTime);
var_dump($res);
var_dump(substr($res[2],0,2));*/
echo time();
echo "\n";
echo md5('8b69a1e567badea06faac3a229dceb3a70da9142150526697435886uW9UN33zCJ');
echo "\n";
$i = 2;
echo md5(uniqid(rand()));
$f =' 12:54';
$day = date("Y-m-d",time());
var_dump(strtotime($day.$f));echo '********************';


var_dump(date("Y-m-d",38658));
var_dump(md5('123456'));
var_dump(date ( "w",strtotime('2017-07-16')));
var_dump(date ( "w",strtotime('2017-07-17')));
var_dump(date ( "w",strtotime('2017-07-18')));
var_dump(date ( "w",strtotime('2017-07-19')));
var_dump(date ( "w",strtotime('2017-07-20')));
var_dump(date ( "w",strtotime('2017-07-21')));
var_dump(date ( "w",strtotime('2017-07-22')));
var_dump(date ( "w",strtotime('2017-07-23')));


var_dump(json_encode(array(array('Date'=>'2016-10-23','Price'=>30254,'Pb'=>684545))));

echo "今天:".date("Y-m-d")."<br>";
echo "昨天:".date("Y-m-d",strtotime("-1 day")), "<br>";
echo "明天:".date("Y-m-d",strtotime("+1 day")). "<br>";
echo "一周后:".date("Y-m-d",strtotime("+1 week")). "<br>";
echo "一周零两天四小时两秒后:".date("Y-m-d G:H:s",strtotime("+1 week 2 days 4 hours 2 seconds")). "\n";
echo "下个星期四:".date("Y-m-d",strtotime("next Thursday")). "\n";
echo "上个周一:".date("Y-m-d",strtotime("last Monday"))."\n";
echo "本周周一:".date("Y-m-d",strtotime("Monday"))."\n";
echo "本周周二:".date("Y-m-d",strtotime("Tuesday"))."\n";
echo "本周周三:".date("Y-m-d",strtotime("Wednesday"))."\n";
echo "本周周四:".date("Y-m-d",strtotime("Thursday"))."\n";
echo "本周周五:".date("Y-m-d",strtotime("Friday"))."\n";
echo "本周周六:".date("Y-m-d",strtotime("Saturday"))."\n";
echo "本周星期天:".date("Y-m-d",strtotime("Sunday"))."\n";
echo "一个月前:".date("Y-m-d",strtotime("last month"))."\n";
echo "一个月后:".date("Y-m-d",strtotime("+1 month"))."\n";
echo "十年后:".date("Y-m-d",strtotime("+10 year"))."\n";

echo "给定日期前几天:".date("Y-m-d",strtotime("2016-11-02 -1 day"))."<br>";


echo "几个小时前".strtotime('2017-03-06')."<br>";
echo "几个小时前".strtotime('2017-03-05')."<br>";
echo "几个小时前".(strtotime('2017-03-05')-strtotime('2017-03-06'))."<br>";
echo date("Y-m-d",time());
//本周一
echo date('Y-m-d', (time() - ((date('w') == 0 ? 7 : date('w')) - 1) * 24 * 3600)); //w为星期几的数字形式,这里0为周日


//本周日

echo date('Y-m-d', (time() + (7 - (date('w') == 0 ? 7 : date('w'))) * 24 * 3600)); //同样使用w,以现在与周日相关天数算


//上周一

echo date('Y-m-d', strtotime('-1 monday', time())); //无论今天几号,-1 monday为上一个有效周未


//上周日

echo date('Y-m-d', strtotime('-1 sunday', time())); //上一个有效周日,同样适用于其它星期


//本月一日

echo date('Y-m-d', strtotime(date('Y-m', time()) . '-01 00:00:00')); //直接以strtotime生成


//本月最后一日

echo date('Y-m-d', strtotime(date('Y-m', time()) . '-' . date('t', time()) . ' 00:00:00')); //t为当月天数,28至31天


//上月一日

echo date('Y-m-d', strtotime('-1 month', strtotime(date('Y-m', time()) . '-01 00:00:00'))); //本月一日直接strtotime上减一个月


//上月最后一日

echo date('Y-m-d', strtotime(date('Y-m', time()) . '-01 00:00:00') - 86400); //本月一日减一天即是上月最后一日